package fast.mvc;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.JPanel;

class RatingPanel extends JPanel {
        
	private static final long serialVersionUID = 1L;
	private double ep;
    private double fill;
    private double curEP;
    private final int width = 260;
    private final int height = 15;
    
    public RatingPanel(double ep, double maxEP) {
    	setValues(ep,maxEP);
    }
    
    public RatingPanel(double ep, double maxEP, double curEP){
    	setValues(ep,maxEP,curEP);
    }
    
    public void setValues(double ep, double maxEP) {
		this.ep = ep;
		fill = this.ep/maxEP;
		setSize(new Dimension(width,height));
		setPreferredSize(new Dimension(width,height));
    }
    
    public void setValues(double ep, double maxEP, double curEP){
    	setValues(ep,maxEP);
    	this.curEP = curEP/maxEP;
    }
    
    public RatingPanel() {
		
	}

	public void paint(Graphics g) {
		g.setColor(Color.CYAN);
		g.fillRect(0, 0, (int)((width-1)*fill), height-1);
		g.setColor(Color.BLACK);
		g.drawRect(0, 0, width-1, height-1);
		if(curEP != 0){
			g.drawLine((int)((width-1)*curEP), 0, (int)((width-1)*curEP), height-1);
		}
    }
        
}